Reshape ================= 对输入张量进行重塑操作。在底层实现上,由于张量形状仅由参数定义,该算子执行从输入地址到输出地址的连续数据拷贝。 .. math:: output_i = input_i 输入: - **input** - 输入数据起始地址。 - **length** - 需拷贝的元素个数。对于复数类型,length 表示复数的个数。 - **core_mask(int, 可选)** - 核掩码(仅适用于共享存储版本)。 输出: - **output** - 输出数据起始地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持 int8, int16, int32, fp32, fp64, c64, c128 - MT7004 支持 fp16, fp32, int16, int32, c64 - 对于复数类型(c64 / c128),算子会自动处理实部和虚部的连续拷贝,其迁移字节数是普通类型的两倍。 **共享存储版本:** .. c:function:: void i8_reshape_s(int8_t* input, int8_t* output, int length, int core_mask) .. c:function:: void i16_reshape_s(int16_t* input, int16_t* output, int length, int core_mask) .. c:function:: void i32_reshape_s(int* input, int* output, int length, int core_mask) .. c:function:: void hp_reshape_s(half* input, half* output, int length, int core_mask) .. c:function:: void fp_reshape_s(float* input, float* output, int length, int core_mask) .. c:function:: void dp_reshape_s(double* input, double* output, int length, int core_mask) .. c:function:: void c64_reshape_s(float* input, float* output, int length, int core_mask) .. c:function:: void c128_reshape_s(double* input, double* output, int length, int core_mask) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 10 //FT78NE示例(共享存储,多核并行拷贝) #include #include "78NE/utils.h" int main(int argc, char* argv[]) { float *input = (float *)0xA0000000; // DDR 空间 float *output = (float *)0xB0000000; // DDR 空间 int length = 960001; int core_mask = 0x0B; // 使用逻辑核 0, 1, 2 fp_reshape_s(input, output, length, core_mask); return 0; } **私有存储版本:** .. c:function:: void i8_reshape_p(int8_t* input, int8_t* output, int length) .. c:function:: void i16_reshape_p(int16_t* input, int16_t* output, int length) .. c:function:: void i32_reshape_p(int32_t* input, int32_t* output, int length) .. c:function:: void hp_reshape_p(half* input, half* output, int length) .. c:function:: void fp_reshape_p(float* input, float* output, int length) .. c:function:: void dp_reshape_p(double* input, double* output, int length) .. c:function:: void c64_reshape_p(float* input, float* output, int length) .. c:function:: void c128_reshape_p(double* input, double* output, int length) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 8 //MT7004 示例(私有存储,单核拷贝) #include int main(int argc, char* argv[]) { float *input = (float *)0x10810000; float *output = (float *)0x10820000; int length = 1024; fp_reshape_p(input, output, length); return 0; }